$(function(){
	var powersArr = document.getElementsByName("optionsRadios");
	powersArr[0].checked=true;
	powersArr[1].checked=true;
	$("#sure").click(role_add);
	console.log("1111");
});
//保存权限
function role_add() {
	var powersArr = document.getElementsByName("optionsRadios");
	if((powersArr[0].checked==true)&&(powersArr[1].checked==true)){
		
		powersArr[0].value="阅读；";
		powersArr[1].value="下载";	
	}else{
		if(powersArr[0].checked==true){
			powersArr[0].value="阅读";
			powersArr[1].value="";
		}else if(powersArr[1].checked==true){
			powersArr[0].value="";
			powersArr[1].value="下载";
		}else{
			powersArr[0].value="";
			powersArr[1].value="";
		}
	}
	
	var rolename=$("#rolename").val().trim();
	var isread=powersArr[0].value;
	var isdown=powersArr[1].value;
	//console.log(rolename);
	//判断角色是否为空
	if(rolename!=0){
	$.ajax({
		url:path+"/role/role_add",
		type:"post",
		data:{"rolename":rolename,"isread":isread,"isdown":isdown},
		dataType:"json",
	success:function(result){
		   
		console.log("succ");
		window.location.href=path+"/role/role_select";
	}
		
	});
}
}



























//var powersARR = new Array();
//判断哪些复选框被选中，取value
/*for (var i = 0; i < powersArr.length; i++) {
	if (powersArr[i].checked == true) {
		//powersARR.push(powersArr[i].value);
		powersArr[i].value=1;
	}else{
		powersArr[i].value=0;
	}
	powersARR.push(powersArr[i].value);
}
for(var i=0;i<powersARR.length;i++){
	console.log(powersARR[i]);
	
}*/


//window.location.href="role.html";
/*//把当前操作的角色id也传回后台
var row = $('#tt').datagrid('getSelected');
var id = row.roleId;
window.location.href = "addrolemenu.do?menuarray=" + menuarray + "&id="
		+ id;
//关闭窗口
$('#w').window('close');*/










